package com.xingkeduo.business.operation.service;

import com.xingkeduo.dao.database.DatabaseAccessObject;
import com.xingkeduo.pojo.query.SystemQuery;
import com.xingkeduo.pojo.table.SystemTable;
import com.xingkeduo.util.tool.CommonUtil;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文件概述
 *
 * @author wangxilong <wangxilong@xingkeduo.com>
 * @version id:v0.1 ${date}${time}
 * @package BeautyOS
 * @copyright Copyright (c) XKD 2019
 */
@Component
public class SystemService {
    private static final String NAMESPACE = SystemTable.class.getSimpleName();

    @Resource(name = "mysqlOperationDao")
    private DatabaseAccessObject<SystemTable, SystemQuery> dao;

    //查询一条
    public SystemTable selectByCode(long code) throws Throwable {
        SystemTable systemTable = dao.select(NAMESPACE, code);
        if (!CommonUtil.isEmpty(systemTable))
            return systemTable;
        return null;
    }

    //查询多条
    public List<SystemTable> selectLists(SystemQuery systemQuery) throws Throwable {
        List<SystemTable> systemTableList = dao.select(NAMESPACE, systemQuery);
        if (!CommonUtil.isEmpty(systemTableList))
            return systemTableList;
        return null;
    }

    //插入
    public int insert(SystemTable systemTable) throws Throwable {
//        systemTable.setCode(IdentityUtil.nextId(Worker.USER));
        return dao.insert(NAMESPACE, systemTable);
    }

    //更新
    public int update(SystemTable systemTable) throws Throwable {
        return dao.update(NAMESPACE, systemTable);
    }
}
